package com.wjx.happensbefore.threadstart;

import com.wjx.happensbefore.Utils;

public class ThreadStartRule {
    private static boolean stop = false;

    public static void main(String[] args) {
        Thread getter = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true){
                    if (stop) {
                        System.out.println("getter stopped.");
                        break;
                    }
                }
            }
        }, "getter");
        Thread updater = new Thread(new Runnable() {
            @Override
            public void run() {
                stop = true;
                System.out.println("updater set stop true.");
                getter.start();
                while (true){

                }
            }
        });
        updater.start();
    }

}
